package report2;

import java.util.Scanner;

public class JavaGrammer {
    public static void main(String[] args) {
        System.out.println("IF-Else 求三个数最大值");
        Scanner sc = new Scanner(System.in);
        int a,b,c;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        System.out.println(getMax(a,b,c));


        System.out.println("SwitchCase 求分数评级");
        a = sc.nextInt();
        getScore(a);

        System.out.println("读名字，直到end结束");
        readName();

        System.out.println("打印四种三角形");
        a = sc.nextInt();
        Triangle(a);

        System.out.println("打印四种三角形，使用break continue");
        a = sc.nextInt();
        TriangleBkCt(a);
    }

    public static int getMax(int a,int b,int c){
        int t;
        if(a>b)
            t = a;
        else
            t = b;

        if(t > c)
            return t;
        else
            return c;
    }
    public static void getScore(int score) {
        score /= 10;
        switch (score){
            case 9:
            case 10:
                System.out.println("A");
                break;
            case 8:
                System.out.println("B");
                break;
            case 7:
                System.out.println("C");
                break;
            case 6:
                System.out.println("D");
                break;
            default:
                System.out.println("F");
        }
    }
    public static void readName() {
        String name;
        Scanner sc = new Scanner(System.in);
        name = sc.next();
        while(!name.equals("end")){
            System.out.println(name);
            name = sc.next();
        }
    }
    public static void Triangle(int a) {
        int i,j;
        final int NUM = a;

        //左下角
        for(i=0;i < NUM;i++){
            for(j=0;j < i+1;j++){
                System.out.print("*");
            }
            System.out.println();
        }

        System.out.println();
        // 右上角
        for(i=0;i < NUM;i++){
            for(j=0;j < i;j++){
                System.out.print(" ");
            }
            for(j=0;j < NUM-i;j++){
                System.out.print("*");
            }
            System.out.println();
        }

        System.out.println();
        // 右下角
        for(i=0;i < NUM;i++){
            for(j=0;j < NUM-i-1;j++){
                System.out.print(" ");
            }
            for(j=0;j < i+1;j++){
                System.out.print("*");
            }
            System.out.println();
        }

        System.out.println();
        // 左上角
        for(i=0;i < NUM;i++){
            for(j=0;j < NUM-i;j++){
                System.out.print("*");
            }
            System.out.println();
        }
        System.out.println();
    }
    public static void TriangleBkCt(int n) {
        int i,j;
        final int NUM = n;

        //左下角
        for(i=0;i < NUM;i++){
            for(j=0;j < i+1;j++){
                if(j == 0) {
                    System.out.print("|");
                    continue;
                }
                System.out.print("*");
            }
            System.out.println();
        }

        System.out.println();
        // 右上角
        for(i=0;i < NUM;i++){
            for(j=0;j < i;j++){
                System.out.print(" ");
            }
            for(j=0;j < NUM-i;j++){
                if(i == 0){
                    System.out.print("_");
                    continue;
                }
                System.out.print("*");
            }
            System.out.println();
        }

        System.out.println();
        // 右下角
        for(i=0;i < NUM;i++){
            for(j=0;j < NUM-i-1;j++){
                System.out.print(" ");
            }
            for(j=0;j < i+1;j++){
                if(i == 2)
                    break;
                System.out.print("*");
            }
            System.out.println();
        }

        System.out.println();
        // 左上角
        for(i=0;i < NUM;i++){
            for(j=0;j < NUM-i;j++){
                System.out.print("*");
            }
            if(i == 2)
                break;
            System.out.println();
        }
        System.out.println();
    }
}
